package com.yami.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yami.shop.bean.model.Product;
import com.yami.shop.bean.model.Rebate;
import com.yami.shop.dao.ProductMapper;
import com.yami.shop.dao.RebateMapper;
import com.yami.shop.service.ProductService;
import com.yami.shop.service.RebateRecordsService;
import com.yami.shop.service.RebateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RebateServiceImpl extends ServiceImpl<RebateMapper, Rebate> implements RebateService {

    @Autowired
    private  RebateMapper rebateMapper;

    @Autowired
    private ProductMapper productMapper;

    @Autowired
    private RebateService rebateService;

    @Override
    public Rebate getRebate(Long shopId, Long prodId) {
        return rebateMapper.getRebate(shopId,prodId);
    }

    @Override
    public boolean saveData(Rebate rebate) {
        Long prodId = rebate.getProdId();
        Product product = new Product();
        product.setProdId(prodId);
        product.setIsSpread(0);
        productMapper.updateById(product);
        return rebateService.save(rebate);
    }

}
